package com.smart_environmental_protection.controller;

import com.smart_environmental_protection.pojo.Content;
import com.smart_environmental_protection.pojo.Notice;
import com.smart_environmental_protection.service.ContentService;
import com.smart_environmental_protection.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class NoticeController {
    @Autowired
    private NoticeService noticeService;


    @PostMapping("/system/events/list")

    public Map<String,Object> NoticeList(){
        Map map=new HashMap<String,Object>();
        List<Notice> noticeList=noticeService.NoticeList();

        if (noticeList!=null){ map.put("success",true);
            map.put("code",200);
            map.put("msg","成功");
            map.put("data",noticeList);



        }else {
            map.put("success",false);
            map.put("msg","失败");
        }
        return map;
    }


    @PostMapping("/system/event")

    public Map<String,Object> NoticeDetail(@RequestBody Notice notice){

        Map map=new HashMap<String,Object>();
        Notice notice1=noticeService.NoticeDetail(notice.getId());

        if (notice1!=null){
            map.put("success",true);
            map.put("code",200);
            map.put("msg","成功");
            map.put("data",notice1);



        }else {
            map.put("success",false);
            map.put("msg","失败");
        }
        return map;
    }




















}
